﻿<UserControl
    x:Class="Srk.BetaseriesApiApp.Views.Query"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:cmd="clr-namespace:Srk.BetaseriesApiApp.Controls"
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="300">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <cmd:EventToCommand Command="{Binding LoadedCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition SharedSizeGroup="QueryCol1" Width="Auto" />
            <ColumnDefinition SharedSizeGroup="QueryCol2" />
        </Grid.ColumnDefinitions>

        <TextBlock Text="Action: " />
        <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Action}" />

        <CheckBox Grid.Row="1" Content="Key" IsChecked="{Binding IsKeyEnabled}" />
        <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Key}" IsEnabled="False" />

        <CheckBox Grid.Row="2" Content="Token" IsChecked="{Binding IsTokenEnabled}" />
        <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Token}" IsEnabled="False" />

        <ItemsControl Grid.Row="4" Grid.ColumnSpan="2"
                                  ItemsSource="{Binding Arguments}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition SharedSizeGroup="QueryCol1" Width="Auto" />
                            <ColumnDefinition SharedSizeGroup="QueryCol2" />
                        </Grid.ColumnDefinitions>

                        <CheckBox IsChecked="{Binding IsEnabled}">
                            <TextBox Text="{Binding Key}" />
                        </CheckBox>
                        <TextBox Grid.Column="1" Text="{Binding Value}" />
                    </Grid>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

        <Button Grid.Row="4" Grid.ColumnSpan="2" HorizontalAlignment="Right" VerticalAlignment="Top"
                            Content="+" Command="{Binding NewArgCommand}" />

        <StackPanel Grid.Row="5" Grid.ColumnSpan="2" Orientation="Horizontal">
            <Button Content="Execute" Command="{Binding ExecuteCommand}" />
            <Button Content="Save" />
        </StackPanel>

        <TextBox Grid.Row="6" Grid.ColumnSpan="2" Text="{Binding QueryString}" IsReadOnly="True" />

        <TextBox Grid.Row="7" Grid.ColumnSpan="2" Text="{Binding Response}"
                             AcceptsReturn="True" AcceptsTab="True" />

        <TextBlock Grid.Row="8" Grid.ColumnSpan="2" Text="{Binding StatusMessage}" Margin="4" />
    </Grid>
</UserControl>
